/** 业务类型与责任部门关系配置表 */
import request from '@/utils/request'

// 查询所有
export function getBusinessDepartRelAll() {
  return request({
    method: 'GET',
    url: `/call-center/api/v2/businessDepartmentRelation/`
  })
}

/** 新增/编辑保存
 * @param {String} businessType 一级业务类型code
 * @param {String} businessTypeName 一级业务类型name
 * @param {String} businessTypeTwo 二级业务类型Code
 * @param {String} businessTypeTwoName 二级业务类型Name
 * @param {String} dept 责任部门code
 * @param {String} deptName 责任部门name
 */
export function saveBusinessDepartRel(data) {
  return request({
    method: data.id ? 'PUT' : 'POST',
    url: '/call-center/api/v2/businessDepartmentRelation',
    data
  })
}

/** 删除
 * @param {String} id 关联ID
 */
export function deleteBusinessDeptRel(id) {
  return request({
    method: 'DELETE',
    url: `/call-center/api/v2/businessDepartmentRelation/${id}`
  })
}

/** 批量删除
 * @param {Array} ids 关联ID集合
 */
export function deleteBatch(ids) {
  return request({
    method: 'DELETE',
    url: `/call-center/api/v2/businessDepartmentRelation/deleteBatch`,
    data: ids
  })
}

/**
 * 获取业务类型指定数据
 * @param {int} parentId 业务类型ParentID
 */
export function getBusinessDeptRelByCode(parentRelationCode) {
  return request({
    method: 'GET',
    url: `/call-center/api/v1/businessDeptRelation/getByParentRelationCode/${parentRelationCode}`
  })
}

/**
 * 根据一级和二级业务类型查询默认责任部门
 */
export function searchBusinessDefaultDept({ businessType, businessTypeTwo }) {
  return request({
    method: 'GET',
    url: `/call-center/api/v2/businessDepartmentRelation/searchBusinessDept`,
    params: { businessType, businessTypeTwo }
  })
}
